package query_understanding.query_language.doc_entity_tree;

import com.codahale.metrics.MetricRegistryListener;
import edu.stanford.nlp.ling.IndexedWord;
import knowlwdge_graph.knowledge_retrival.yago_retrival.YagoEntityRereival;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by julianzliu on 4/22/2017.
 */
public class QueryEdge {


    public enum EdgeType {
        YAGO_EDGE, OCCUR_EDGE, TYPE_EDGE
    }


    public static class BaseEdge  extends QueryElement.AbstractQueryElement {

        public EdgeType edgeType;

        // 克隆对象
        public Set<QueryNode.BaseNode> nodesSet;

         /*
        求解过程中，先进行一次从根开始的遍历，临时生成
         */
        public QueryNode.BaseNode in;
        public QueryNode.BaseNode out;
        public Boolean solved;
        public Boolean solveable;





        public BaseEdge(){
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
            this.solveable = false;
            this.solved = false;
            this.nodesSet = new HashSet<>();
        }
    }


    public static class YagoEdge extends BaseEdge {


        public String yago_id;

        public String yago_label;

        public Double score;

        public IndexedWord mainToken;

        public List<IndexedWord> allTokens;

        public YagoEdge(){
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
            this.edgeType = EdgeType.YAGO_EDGE;
        }

        public YagoEdge copy(){
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
            this.edgeType = EdgeType.YAGO_EDGE;
            YagoEdge new_edge = new YagoEdge();
            new_edge.nodesSet = new HashSet<>();
            new_edge.yago_label = this.yago_label;
            new_edge.yago_id = this.yago_id;
            new_edge.score = this.score;
            new_edge.mainToken = this.mainToken;
            new_edge.allTokens = this.allTokens;
            return new_edge;
        }

    }



    public static class OccurEdge extends  BaseEdge {

        /*
        occur_with边代表的文本
         */
        public String text;

        public Double score;

        public IndexedWord mainToken;

        public List<IndexedWord> allTokens;

        public OccurEdge(){
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
            this.edgeType = EdgeType.OCCUR_EDGE;
        }

        public OccurEdge copy(){
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
            this.edgeType = EdgeType.OCCUR_EDGE;
            OccurEdge new_edge = new OccurEdge();
            new_edge.nodesSet = new HashSet<>();
            new_edge.text = this.text;
            new_edge.score = this.score;
            new_edge.mainToken = this.mainToken;
            new_edge.allTokens = this.allTokens;
            return new_edge;
        }
    }


    public static class TypeEdge extends BaseEdge {
        /*
        rdf:type 代表的边
        总是最后执行
         */
        public IndexedWord mainToken;

        public TypeEdge(){
            this.nodesSet = new HashSet<>();
            this.edgeType = EdgeType.TYPE_EDGE;
            this.elementType = QueryElement.ElementType.EDGE_TYPE;
        }

        public TypeEdge copy(){
            TypeEdge new_edge = new TypeEdge();
            return new_edge;
        }

    }


}
